package binscope

// Columns Excel列编号，用于通过对应的索引找Axis（当前仅包含支持A-Z）
var Columns = [26]string{
	"A", "B", "C", "D", "E", "F", "G",
	"H", "I", "J", "K", "L", "M", "N",
	"O", "P", "Q", "R", "S", "T",
	"U", "V", "W", "X", "Y", "Z"}

// DetailSheetName 二进制结果分析表格详细内容的Sheet页名
const DetailSheetName = "Detail"

const (
	// HeaderSuffix 二进制分析结果分析完成后的表格，在原始表头之后添加的后缀
	HeaderSuffix = "_分析结果"
	// HeaderFinalResult 分析结果表格中分析结论汇总的表头内容
	HeaderFinalResult = "分析结果汇总"
	// HeaderKeywordPath 分析结果表格中填写匹配关键词的表头内容
	HeaderKeywordPath = "关键路径"
	// HeaderFilePath FilePath
	HeaderFilePath = "FilePath"
	// HeaderObject Object
	HeaderObject = "Object"
	// HeaderBindNow BIND_NOW
	HeaderBindNow = "BIND_NOW"
	// HeaderBindNowAfter BIND_NOW
	HeaderBindNowAfter = HeaderBindNow + HeaderSuffix
	// HeaderNX NX
	HeaderNX = "NX"
	// HeaderNXAfter NX
	HeaderNXAfter = HeaderNX + HeaderSuffix
	// HeaderPIC PIC
	HeaderPIC = "PIC"
	// HeaderPICAfter PIC
	HeaderPICAfter = HeaderPIC + HeaderSuffix
	// HeaderPIE PIE
	HeaderPIE = "PIE"
	// HeaderPIEAfter PIE
	HeaderPIEAfter = HeaderPIE + HeaderSuffix
	// HeaderRELRO RELRO
	HeaderRELRO = "RELRO"
	// HeaderRELROAfter RELRO
	HeaderRELROAfter = HeaderRELRO + HeaderSuffix
	// HeaderSP SP
	HeaderSP = "SP"
	// HeaderSPAfter SP
	HeaderSPAfter = HeaderSP + HeaderSuffix
	// HeaderRpath NO Rpath/RunPath
	HeaderRpath = "NO Rpath/RunPath"
	// HeaderRpathAfter NO Rpath/RunPath
	HeaderRpathAfter = HeaderRpath + HeaderSuffix
	// HeaderFS FS
	HeaderFS = "FS"
	// HeaderFSAfter FS
	HeaderFSAfter = HeaderFS + HeaderSuffix
	// HeaderFtrapv Ftrapv
	HeaderFtrapv = "Ftrapv"
	// HeaderFtrapvAfter Ftrapv
	HeaderFtrapvAfter = "Ftrapv" + HeaderSuffix
	// HeaderStrip Strip
	HeaderStrip = "Strip"
	// HeaderStripAfter Strip
	HeaderStripAfter = HeaderStrip + HeaderSuffix
)

// HeadersBefore 二进制分析结果原始Excel表格中的表头序列
var HeadersBefore = []string{
	HeaderFilePath, HeaderObject, HeaderBindNow, HeaderNX, HeaderPIC, HeaderPIE,
	HeaderRELRO, HeaderSP, HeaderRpath, HeaderFS, HeaderFtrapv, HeaderStrip}

// HeadersBeforeIndexMap 记录二进制分析结果原始Excel表格表头及其对应索引的字典
var HeadersBeforeIndexMap = GetHeadersIndexMap(HeadersBefore)

// HeadersAfter 二进制分析结果Excel表格中的表头序列
var HeadersAfter = []string{
	HeaderFilePath, HeaderObject, HeaderFinalResult, HeaderKeywordPath,
	HeaderBindNow, HeaderBindNowAfter, HeaderNX, HeaderNXAfter,
	HeaderPIC, HeaderPICAfter, HeaderPIE, HeaderPIEAfter,
	HeaderRELRO, HeaderRELROAfter, HeaderSP, HeaderSPAfter,
	HeaderRpath, HeaderRpathAfter, HeaderFS, HeaderFSAfter,
	HeaderFtrapv, HeaderFtrapvAfter, HeaderStrip, HeaderStripAfter}

// HeadersAfterIndexMap 记录二进制分析结果原始Excel表格表头及其对应索引的字典
var HeadersAfterIndexMap = GetHeadersIndexMap(HeadersAfter)

// HeadersAbnormalValueMap 记录而二进制分析内容与异常结果的对应关系
var HeadersAbnormalValueMap = map[string]string{
	HeaderBindNow: ResultNo,
	HeaderNX:      ResultNo,
	HeaderPIC:     ResultNo,
	HeaderPIE:     ResultNo,
	HeaderRELRO:   ResultNo,
	HeaderSP:      ResultNo,
	HeaderRpath:   ResultYes,
	HeaderFS:      ResultToDo,
	HeaderFtrapv:  ResultToDo,
	HeaderStrip:   ResultToDo,
}

// GetHeadersIndexMap 根据顺序的Excel表格头及其索引组成的字典，用来查询表头对一个的索引
func GetHeadersIndexMap(headers []string) map[string]int {
	m := map[string]int{}
	for i, header := range headers {
		m[header] = i
	}
	return m
}

// Keywords 更新路径的关键词
var Keywords = []string{
	"layer.tar_/layer",
	"layer.tar_",
}

const (
	// ResultNo 编译选项结果中的NO
	ResultNo = "NO"
	// ResultYes 编译选项结果中的YES
	ResultYes = "YES"
	// ResultUnused 编译选项结果中的UNUSED
	ResultUnused = "UNUSED"
	// ResultNA 编译选项结果中的NA
	ResultNA = "NA"
	// ResultToDo 编译选项结果中的TODO
	ResultToDo = "TODO"
)

const (
	// StyleStringHeader 二进制扫描结果中表头内容的样式
	// `{"fill":{"type":"pattern","color":["#CCFFCC"],"pattern":1}, "font":{"bold":true,"italic":true,"family":"Times New Roman","size":36,"color":"#777777"}}`
	// `{"alignment":{"horizontal":"center","ident":1,"justify_last_line":true,"reading_order":0,"relative_indent":1,"shrink_to_fit":true,"text_rotation":45,"vertical":"","wrap_text":true}}`
	StyleStringHeader = `{"fill":{"type":"pattern","color":["#CCFFCC"],"pattern":1}, "font":{"bold":true}, "alignment":{"horizontal":"center"}}`
	// StyleStringPassed 二进制扫描结果中通过内容的样式
	StyleStringPassed = `{"fill":{"type":"pattern","color":["#00FF00"],"pattern":1}}`
	// StyleStringFailed 二进制扫描结果中失败内容的样式
	StyleStringFailed = `{"fill":{"type":"pattern","color":["#FF0000"],"pattern":1}}`
	// StyleStringUnused 二进制扫描结果中未使用内容的样式
	StyleStringUnused = `{"fill":{"type":"pattern","color":["#808080"],"pattern":1}}`
)
